<include file="/public/header" />
<style>
    .layui-table-cell {
        overflow: visible;
        text-overflow: inherit;
        white-space: normal;
        height: auto;
        /*在这里设置行高没用*/
    }
</style>
<!-- // 列表工具栏 -->
<script type="text/html" id="tableBar">
    <a class="layui-table-text" data-title="{:__('编辑')} {{d.title}}" 
        data-area="762px,95%" data-url="{:url('/system/material/fadd')}?id={{d.id}}"  lay-event="edit" >{:__('编辑')}</a>
</script>
<div class="layui-fluid">
    <div class="layui-card">
        <!-- // 默认操作按钮 -->
        <div class="layui-card-header layadmin-card-header-auto ">
            <div class="layui-form">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <select name="materialid" lay-search="" >
                                <option value="">{:__('原材料')}</option>
                                <foreach $material as $v>
                                    <option value="{$v.id}" <if input('materialid') == $v.id>selected</if>>{$v.title}
                                    </option>
                                </foreach>
                            </select>                        
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <select name="supplierid" lay-search="" >
                                <option value="">{:__('供应商')}</option>
                                <foreach $supplier as $v>
                                    <option value="{$v.id}" >{$v.title}
                                    </option>
                                </foreach>
                            </select>                        
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline ">
                            <input type="text" name="title" class="layui-input" placeholder="期数查询">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <!-- // 默认搜索 -->
                        <button class="layui-btn icon-btn" lay-filter="formSearch" lay-submit><i
                                class="layui-icon layui-icon-search"></i>{:__('搜索')}</button>
                        <div class="layui-divider layui-divider-vertical"></div>
                    </div>
                </div>
            </div>
        </div>

        <!-- // 创建数据实例 -->
        <table id="lay-tableList" lay-filter="lay-tableList"></table>
    </div>
</div>
<include file="/public/footer" />
<script>
    layui.use(['admin', 'layedit', 'table', 'form', 'content'], function () {
        var admin = layui.admin;
        var table = layui.table;
        var form = layui.form;
        /*
         * 初始化表格
        */
        var isTable = table.render({
            elem: "#lay-tableList"
            , url: "{:url('/system/material/materialprice')}"
            , where: {
                materialid: "{:input('materialid')}"
            }
            , page: true
            , limit: 18
            , cols: [[
                { field: 'id', align: 'center', sort: true, width: 80, title: 'ID' },
                { field: 'materialtitle', align: 'left', title: '{:__("原材料名称")}' },
                {
                    field: 'images', align: 'center', width: 100, templet: function (d) {
                        var text = '<div>'
                        d.images.forEach(e => {
                            text += '<div><img src="' + e + '" width="50" height="50" lay-image-hover="" ></div>';
                        });

                        text +='</div>';
                        return text;
                    }, title: '凭据'
                },
                { field: 'supplier', align: 'left', title: '{:__("供应商")}' },
                { field: 'mobile', align: 'left', title: '{:__("供应商联系电话")}' },
                { field: 'dates', align: 'left', title: '{:__("进货日期")}' },
                { field: 'getdates', align: 'left', title: '{:__("到货日期")}' },
                { field: 'weight', align: 'left', title: '{:__("进货重量")}' },
                { field: 'price', align: 'left', title: '{:__("每kg单价")}' },
                { field: 'totals', align: 'left', title: '{:__("总价")}' },
                { field: 'create_time', align: 'left', title: '{:__("添加时间")}' },
                { align: 'center', toolbar: '#tableBar', width: 160, title: '{:__("操作")}' },

            ]],
            done: function () {
                //当数据渲染完后，执行的回调
            }
        })
    })
</script>